@tool
extends PickableComponent


@onready var sprite_2d: Sprite2D = $Sprite2D
@onready var animated_sprite_2d: AnimatedSprite2D = $AnimatedSprite2D


func set_item(value: InventoryItem) ->void:
    super.set_item(value)
    if item and item.source:
        if item.source.icon_floor:
            animated_sprite_2d.sprite_frames = item.source.icon_floor
            NodeHelper.play_animation(animated_sprite_2d, "default")
            sprite_2d.texture = null
            sprite_2d.visible = false
            animated_sprite_2d.visible = true
        else:
            animated_sprite_2d.sprite_frames = null
            sprite_2d.texture = item.source.icon
            sprite_2d.visible = true
            animated_sprite_2d.visible = false
    else:
        animated_sprite_2d.sprite_frames = null
        sprite_2d.texture = null

func _ready() -> void:
    set_item(item)
